#define _CRT_SECURE_NO_WARNINGS 1
#include "process.h"

#define TOTAL 1024.0
#define SPEED 1.0
#define FLOAT 4.3

void Dowload(double total) {
    double cur = 0;
    int int_float = (int)FLOAT;
    double speed = SPEED + rand() % int_float + (FLOAT - int_float);

    while (cur <= total) {
        process(total, cur);
        cur += speed;
        if (cur > total) {
            cur = total;
            process(total, cur);
            break;
        }
        usleep(30000);
    }

    printf("success\n");
}


int main() {
    srand(time(NULL));

    printf("dowload:%.1lf\n", TOTAL);
    Dowload(TOTAL);

    printf("dowload:%.1lf\n", 200.0);
    Dowload(200.0);

    printf("dowload:%.1lf\n", 50.0);
    Dowload(50.0);

    printf("dowload:%.1lf\n", 20000.0);
    Dowload(20000.0);

    return 0;
}